package com.bwf.set;

import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;

/**
 * @Version v1.0
 * @Description: TODO
 * @Author ZHANZHONGXIN
 * @Date 2022/5/23 15:24
 * @Copyright 博为峰
 */
public class HashSetDemo {
    public static void main(String[] args) {
//        m1();
        //存储Student对象，并遍历
        final HashSet hashSet = new HashSet();
        hashSet.add(new Student("张三", 20));
        hashSet.add(new Student("李四", 30));
        hashSet.add(new Student("张三", 20));

        final Iterator iterator = hashSet.iterator();
        while (iterator.hasNext()) {
            final Student student = (Student) iterator.next();
            System.out.println(student);
        }

    }

    private static void m1() {
        final HashSet hashSet = new HashSet();
        hashSet.add("b");
        hashSet.add("a");
        hashSet.add("c");
        hashSet.add("a");

        System.out.println(hashSet);
    }
}
